package com.orgcent.activities;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.TextView;
/**
 * 测试共享配置文件，SharedPreference
 */
public class TestSharedPreference extends Activity {

	private static final String COUNT = "count";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		final TextView stat_tv = new TextView(this);
		
		SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
		
		int count = sp.getInt(COUNT, 0);
		
		stat_tv.setText("此Activity已运行了" + count + "次");
		
		SharedPreferences.Editor edit = sp.edit();
		edit.putInt(COUNT, ++count);
		edit.commit();
		
		setContentView(stat_tv);
	}

}
